﻿@model TrucksDir.Data.item
@using TrucksDir.Data;
@using TrucksDir.Data.Services;
@using TrucksDir.Resources
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
    HtmlHelper.ClientValidationEnabled = true;
    //HtmlHelper.UnobtrusiveJavaScriptEnabled = true;
}
@*<script src="@Url.Content("~/Scripts/jquery.validate.js")%>" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcValidation.js")%>" type="text/javascript"></script>*@


<script language="javascript" type="text/javascript">
    function validateFirst() {
        var isValid = true;

        //Name
//        if (document.getElementById("Name").value == "") {
//            document.getElementById("Name").setAttribute("class", "input-validation-error");
//            document.getElementById("NameVal").setAttribute("class", "field-validation-error");
//            document.getElementById("Name").focus();
//            isValid = false;
//        }
//        else {
//            document.getElementById("Name").setAttribute("class", "");
//            document.getElementById("NameVal").setAttribute("class", "field-validation-valid");
//        }

        //RadioButton Type
        if (valButton(document.getElementsByName("type.Name")) == null) {
            document.getElementById("TypeVal").setAttribute("class", "field-validation-error");
            isValid = false;
        }
        else {
            document.getElementById("TypeVal").setAttribute("class", "field-validation-valid");
        }

        //Brand
        if (document.getElementById("Brand").value == "") {
            document.getElementById("Brand").setAttribute("class", "input-validation-error");
            document.getElementById("BrandVal").setAttribute("class", "field-validation-error");
            document.getElementById("Brand").focus();
            isValid = false;
        }
        else {
            document.getElementById("Brand").setAttribute("class", "");
            document.getElementById("BrandVal").setAttribute("class", "field-validation-valid");
        }

        //second fase
        if (isValid) {

            $(document.getElementById("addTruckFirst")).fadeOut(1000, function () {
                $(document.getElementById("addTruckSecond")).fadeIn(600);});
        }

        return isValid;
    }
    function validateSecond() {
    }
</script>

  
 <div class="cajita-well">
    <div class="cajita-wrapper">
        <div class="cajita">
            <div class="arrow"></div>
                <div class="inner">
                <h3 class="title">
                   Publish your vehicle
                    <small>oh right!</small>
                 </h3>
                 <div class="content">
                    @using (@Html.BeginForm("Create", "Trucks", FormMethod.Post, new { @class = "form-horizontal", @id="truckForm"}))
                    {        
                      <div id="addTruckFirst">               
                       @* <div class="control-group">
                            <label class="control-label" for="Name">
                            Title
                            <i class="icon-info-sign" title="Enter your vehicle TITLE here"></i>
                            </label>
                            <div class="controls">
                                <div class="editor-field">
                                    @Html.TextBoxFor(model => model.Name, new { id="Name", style="width:350px" })                           
                                </div>
                                <p>@Html.ValidationMessageFor(model => model.Name, "Name is invalid", new { id = "NameVal" })</p>
                            </div>
                        </div>*@
                        <div class="control-group">
                         <label class="control-label" for="index_type">
                            Select Vehicle Type
                             <i class="icon-info-sign" title="Choose your Vehicle CATEGORY"></i>
                             <p> @Html.ValidationMessageFor(model => model.type, "Select a type »", new { id = "TypeVal" })</p>               
                         </label>                    
                         <div class="controls">
                          @Html.Partial("Controls/_categories")                  
                         </div>
                        </div>     
                        <div class="control-group">
                            <label class="control-label" for="Brand">
                            Brand
                            <i class="icon-info-sign" title="Enter your vehicle Brand here"></i>
                            </label>
                            <div class="controls">
                                <div class="editor-field">
                                    @Html.DropDownListFor(c => c.ID_Brand, new SelectList(BaseDAO<brand>.GetList(), "ID", "Name"))                          
                                </div>
                                <p>@Html.ValidationMessageFor(model => model.brand, "Brand is invalid", new { id = "BrandVal" })</p>
                            </div>
                        </div>
                        <input type="button" onclick="return validateFirst()"  class="btn btn-primary" value="Next »" style="float:right;font-weight:bold;font-size:18px;"  />
                    </div>          
                      <div id="addTruckSecond" style="display:none;">
                        <div class="control-group">
                            <label class="control-label" for="Name">
                            Reference
                            <i class="icon-info-sign" title="Enter your vehicle TITLE here"></i>
                            </label>
                            <div class="controls">
                                <div class="editor-field">
                                    @Html.TextBoxFor(model => model.Reference, new { id="Ref", style="width:350px" })                           
                                </div>
                                <p>@Html.ValidationMessageFor(model => model.Reference, "Name is invalid", new { id = "RefVal" })</p>
                        </div>
                        </div>
                         <input type="submit" onclick="return validateSecond()"  class="btn btn-primary" value="Next »" style="float:right;font-weight:bold;font-size:18px;"  />
                      </div>
                      <br />
                    } 
                 </div>
            </div>
        </div>
    </div>
</div>
